use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct yata::indicators::SMIErgodicIndicator
///
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct SEI {
    /// 1 signals
    ///Signal #1 on SMI crosses Signal
    ///When Signal line value is below -zone and SMI value crosses Signal line upwards, returns full buy signal.
    ///  When Signal line value is above +zone and SMI value crosses Signal line downwards, returns full sell signal.
    /// Otherwise returns no signal.
    pub signal0: Option<IndicatorActionWrap>,

    ///SMI main value
    ///Range in [-1.0; 1.0]
    pub main: ValueType,

    ///Signal line value
    ///Range in [-1.0; 1.0]
    pub signal: ValueType,

    ///Oscillator value
    ///Range in [-2.0; 2.0]
    pub oscillator: ValueType,
}

/// Configuration
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct SEIConfig {
    /// period1: PeriodType
    ///Long TSI period. Default is 20.
    ///
    ///Range in [period2, PeriodType::MAX).
    pub period1: PeriodType,
    ///
    ///period2: PeriodType
    ///Short TSI period. Default is 5.
    ///
    ///Range in (2, period1].
    ///
    pub period2: PeriodType,
    ///signal: M
    ///Signal line moving average type.
    ///
    ///Default is EMA(5).
    ///
    ///Period range is in [2, PeriodType::MAX).
    ///
    pub signal: PeriodType,
    ///zone: ValueType
    ///Signal zone size. Default is 0.2.

    ///Range in [0.0; 1.0]
    pub zone: ValueType,
    // source: Source
    // Source type of values. Default is Close
}

impl Default for SEIConfig {
    fn default() -> Self {
        Self {
            period1: 20,
            period2: 5,
            signal: 5,
            zone: 0.2,
        }
    }
}
